import turtle

def p (bracnch_lenght):

    if bracnch_lenght > 8:
        turtle.forward(bracnch_lenght)
        turtle.right(30)
        p(bracnch_lenght - 10)

        turtle.left(60)
        p(bracnch_lenght - 10)

        #返回之前的树枝路径
        turtle.right(30)
        turtle.backward(bracnch_lenght)



def main():
    turtle.left(90)
    turtle.penup()
    turtle.backward(150)
    turtle.pendown()
    turtle.color('red')
    p(90)
    turtle.exitonclick()

if __name__ == '__main__':
    main()